#!/bin/bash
#This is a backup script for Oracle.
#数组方式备份
# File save time is 7 days.
PWD="123.com"
bapath="/home/oracle/DBfile/"
if [ ! -d $bapath ];then
  mkdir -p $bapath
fi
filename=`date +%Y-%m-%d`'.bmp'
logname=`date +%Y-%m-%d`'.log'
User=(GPSUSER FNL_PROB ESBUSER)
Pwd=(GPS_user123 pls_fnl_1q pls_esb_1q)

for I in `seq 0 2`
do 
	exp `echo ${User[${I}]}`/`echo ${Pwd[${I}]}`@it-arch file=${bapath}`echo ${User[${I}]}`-${filename} log=${bapath}`echo ${User[${I}]}`-${logname}
	cd $bapath
	tar zcf `echo ${User[${I}]}`-$filename.tar.gz `echo ${User[${I}]}`-$filename
	tar zcf `echo ${User[${I}]}`-$logname.tar.gz `echo ${User[${I}]}`-$logname
	find $bapath -mtime +7 -name "*.bmp.tar.gz" -exec rm -rf {} \;
	find $bapath -mtime +7 -name "*.log.tar.gz" -exec rm -rf {} \;
done
rm -rf ${bapath}*.bmp
rm -rf ${bapath}*.log

